var http = require("http");
var fs = require("fs");
var url = require("url");

//基本的静态文件服务
http
  .createServer(function (request, response) {
    const pathname = url.parse(request.url).pathname;
    fs.readFile(pathname.substr(1), (err, data) => {
      if (err) {
        console.log(err);
        response.writeHead(404, { "Content-type": "text/html" });
        return;
      } else {
        response.end(data);
      }
    });
  })
  .listen(9009);

console.log("Server running at http://localhost:9009/index.html");
